home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / irobot.c < prev    next >
C/C++ Source or Header  |  2000-05-04  |  13KB  |  373 lines

  1. /****************************************************************************
  2. I-Robot Memory Map
  3.  
  4. 0000 - 07FF  R/W    RAM
  5. 0800 - 0FFF  R/W    Banked RAM
  6. 1000 - 1000  INRD1  Bit 7 = Right Coin
  7.                     Bit 6 = Left Coin
  8.                     Bit 5 = Aux Coin
  9.                     Bit 4 = Self Test
  10.                     Bit 3 = ?
  11.                     Bit 2 = ?
  12.                     Bit 1 = ?
  13.                     Bit 0 = ?
  14. 1040 - 1040  INRD2  Bit 7 = Start 1
  15.                     Bit 6 = Start 2
  16.                     Bit 5 = ?
  17.                     Bit 4 = Fire
  18.                     Bit 3 = ?
  19.                     Bit 2 = ?
  20.                     Bit 1 = ?
  21.                     Bit 0 = ?
  22. 1080 - 1080  STATRD Bit 7 = VBLANK
  23.                     Bit 6 = Polygon generator done
  24.                     Bit 5 = Mathbox done
  25.                     Bit 4 = Unused
  26.                     Bit 3 = ?
  27.                     Bit 2 = ?
  28.                     Bit 1 = ?
  29.                     Bit 0 = ?
  30. 10C0 - 10C0  INRD3  Dip switch
  31. 1140 - 1140  STATWR Bit 7 = Select Polygon RAM banks
  32.                     Bit 6 = BFCALL
  33.                     Bit 5 = Cocktail Flip
  34.                     Bit 4 = Start Mathbox
  35.                     Bit 3 = Connect processor bus to mathbox bus
  36.                     Bit 2 = Start polygon generator
  37.                     Bit 1 = Select polygon image RAM bank
  38.                     Bit 0 = Erase polygon image memory
  39. 1180 - 1180  OUT0   Bit 7 = Alpha Map 1
  40.                     Bit 6,5 = RAM bank select
  41.                     Bit 4,3 = Mathbox memory select
  42.                     Bit 2,1 = Mathbox bank select
  43. 11C0 - 11C0  OUT1   Bit 7 = Coin Counter R
  44.                     Bit 6 = Coin Counter L
  45.                     Bit 5 = LED2
  46.                     Bit 4 = LED1
  47.                     Bit 3,2,1 = ROM bank select
  48. 1200 - 12FF  R/W    NVRAM (bits 0..3 only)
  49. 1300 - 13FF  W      Select analog controller
  50. 1300 - 13FF  R      Read analog controller
  51. 1400 - 143F  R/W    Quad Pokey
  52. 1800 - 18FF         Palette RAM
  53. 1900 - 1900  W      Watchdog reset
  54. 1A00 - 1A00  W      FIREQ Enable
  55. 1B00 - 1BFF  W      Start analog controller ADC
  56. 1C00 - 1FFF  R/W    Character RAM
  57. 2000 - 3FFF  R/W    Mathbox/Vector Gen Shared RAM
  58. 4000 - 5FFF  R      Banked ROM
  59. 6000 - FFFF  R      Fixed ROM
  60.  
  61. ****************************************************************************/
  62.  
  63. #include "driver.h"
  64. #include "vidhrdw/generic.h"
  65. #include "cpu/m6809/m6809.h"
  66.  
  67. extern int  irobot_vh_start(void);
  68. extern void irobot_vh_stop(void);
  69. extern void irobot_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom);
  70. extern void irobot_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  71. WRITE_HANDLER( irobot_paletteram_w );
  72.  
  73. void init_irobot(void);    /* convert mathbox ROMs */
  74. void irobot_init_machine (void);
  75.  
  76. READ_HANDLER( irobot_status_r );
  77. WRITE_HANDLER( irobot_statwr_w );
  78. WRITE_HANDLER( irobot_out0_w );
  79. WRITE_HANDLER( irobot_rom_banksel_w );
  80. READ_HANDLER( irobot_control_r );
  81. WRITE_HANDLER( irobot_control_w );
  82. READ_HANDLER( irobot_sharedmem_r );
  83. WRITE_HANDLER( irobot_sharedmem_w );
  84.  
  85.  
  86.  
  87. static unsigned char *nvram;
  88. static size_t nvram_size;
  89.  
  90. static void nvram_handler(void *file, int read_or_write)
  91. {
  92.     if (read_or_write)
  93.         osd_fwrite(file,nvram,nvram_size);
  94.     else
  95.     {
  96.         if (file)
  97.             osd_fread(file,nvram,nvram_size);
  98.         else
  99.             memset(nvram,0,nvram_size);
  100.     }
  101. }
  102.  
  103. WRITE_HANDLER( irobot_nvram_w )
  104. {
  105.     nvram[offset] = data & 0x0f;
  106. }
  107.  
  108.  
  109. static WRITE_HANDLER( irobot_clearirq_w )
  110. {
  111.     cpu_set_irq_line(0, M6809_IRQ_LINE ,CLEAR_LINE);
  112. }
  113.  
  114. static WRITE_HANDLER( irobot_clearfirq_w )
  115. {
  116.     cpu_set_irq_line(0, M6809_FIRQ_LINE ,CLEAR_LINE);
  117. }
  118.  
  119.  
  120. static struct MemoryReadAddress readmem[] =
  121. {
  122.     { 0x0000, 0x07ff, MRA_RAM },
  123.     { 0x0800, 0x0fff, MRA_BANK2 },
  124.     { 0x1000, 0x103f, input_port_0_r },
  125.     { 0x1040, 0x1040, input_port_1_r },
  126.     { 0x1080, 0x1080, irobot_status_r },
  127.     { 0x10c0, 0x10c0, input_port_3_r },
  128.     { 0x1200, 0x12ff, MRA_RAM },
  129.     { 0x1300, 0x13ff, irobot_control_r },
  130.     { 0x1400, 0x143f, quad_pokey_r },
  131.     { 0x1c00, 0x1fff, MRA_RAM },
  132.     { 0x2000, 0x3fff, irobot_sharedmem_r },
  133.     { 0x4000, 0x5fff, MRA_BANK1 },
  134.     { 0x6000, 0xffff, MRA_ROM },
  135.     { -1 }    /* end of table */
  136. };
  137.  
  138. static struct MemoryWriteAddress writemem[] =
  139. {
  140.     { 0x0000, 0x07ff, MWA_RAM },
  141.     { 0x0800, 0x0fff, MWA_BANK2 },
  142.     { 0x1100, 0x1100, irobot_clearirq_w },
  143.     { 0x1140, 0x1140, irobot_statwr_w },
  144.     { 0x1180, 0x1180, irobot_out0_w },
  145.     { 0x11c0, 0x11c0, irobot_rom_banksel_w },
  146.     { 0x1200, 0x12ff, irobot_nvram_w, &nvram, &nvram_size },
  147.     { 0x1400, 0x143f, quad_pokey_w },
  148.     { 0x1800, 0x18ff, irobot_paletteram_w },
  149.     { 0x1900, 0x19ff, MWA_RAM },            /* Watchdog reset */
  150.     { 0x1a00, 0x1a00, irobot_clearfirq_w },
  151.     { 0x1b00, 0x1bff, irobot_control_w },
  152.     { 0x1c00, 0x1fff, MWA_RAM, &videoram, &videoram_size },
  153.     { 0x2000, 0x3fff, irobot_sharedmem_w},
  154.     { 0x4000, 0xffff, MWA_ROM },
  155.     { -1 }  /* end of table */
  156. };
  157.  
  158.  
  159.  
  160. INPUT_PORTS_START( irobot )
  161.     PORT_START    /* IN0 */
  162.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
  163.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
  164.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
  165.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
  166.     PORT_SERVICE( 0x10, IP_ACTIVE_LOW )
  167.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN3 )
  168.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 )
  169.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 )
  170.  
  171.     PORT_START    /* IN1 */
  172.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
  173.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
  174.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
  175.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
  176.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
  177.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
  178.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START2 )
  179.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START1 )
  180.  
  181.     PORT_START    /* IN2 */
  182.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
  183.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
  184.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
  185.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
  186.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
  187.     PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN ) /* MB DONE */
  188.     PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN ) /* EXT DONE */
  189.     PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_VBLANK )
  190.  
  191.     PORT_START /* DSW1 */
  192.     PORT_DIPNAME(    0x03, 0x00, "Coins Per Credit" )
  193.     PORT_DIPSETTING( 0x00, "1 Coin 1 Credit" )
  194.     PORT_DIPSETTING( 0x01, "2 Coins 1 Credit" )
  195.     PORT_DIPSETTING( 0x02, "3 Coins 1 Credit" )
  196.     PORT_DIPSETTING( 0x03, "4 Coins 1 Credit" )
  197.     PORT_DIPNAME(    0x0c, 0x00, "Right Coin" )
  198.     PORT_DIPSETTING( 0x00, "1 Coin for 1 Coin Unit" )
  199.     PORT_DIPSETTING( 0x04, "1 Coin for 4 Coin Units" )
  200.     PORT_DIPSETTING( 0x08, "1 Coin for 5 Coin Units" )
  201.     PORT_DIPSETTING( 0x0c, "1 Coin for 6 Coin Units" )
  202.     PORT_DIPNAME(    0x10, 0x00, "Left Coin" )
  203.     PORT_DIPSETTING( 0x00, "1 Coin for 1 Coin Unit" )
  204.     PORT_DIPSETTING( 0x10, "1 Coin for 2 Coin Units" )
  205.     PORT_DIPNAME(    0xe0, 0x00, "Bonus Adder" )
  206.     PORT_DIPSETTING( 0x00, "None" )
  207.     PORT_DIPSETTING( 0x20, "1 Credit for 2 Coin Units" )
  208.     PORT_DIPSETTING( 0xa0, "1 Credit for 3 Coin Units" )
  209.     PORT_DIPSETTING( 0x40, "1 Credit for 4 Coin Units" )
  210.     PORT_DIPSETTING( 0x80, "1 Credit for 5 Coin Units" )
  211.     PORT_DIPSETTING( 0x60, "2 Credits for 4 Coin Units" )
  212.     PORT_DIPSETTING( 0xe0, DEF_STR( Free_Play ) )
  213.  
  214.     PORT_START /* DSW2 */
  215.     PORT_DIPNAME(    0x01, 0x01, "Language" )
  216.     PORT_DIPSETTING( 0x01, "English" )
  217.     PORT_DIPSETTING( 0x00, "German" )
  218.     PORT_DIPNAME(    0x02, 0x02, "Min Game Time" )
  219.     PORT_DIPSETTING( 0x00, "90 Sec" )
  220.     PORT_DIPSETTING( 0x02, "3 Lives" )
  221.     PORT_DIPNAME(    0x0c, 0x0c, DEF_STR( Bonus_Life ) )
  222.     PORT_DIPSETTING( 0x08, "None" )
  223.     PORT_DIPSETTING( 0x0c, "20000" )
  224.     PORT_DIPSETTING( 0x00, "30000" )
  225.     PORT_DIPSETTING( 0x04, "50000" )
  226.     PORT_DIPNAME(    0x30, 0x30, DEF_STR( Lives ) )
  227.     PORT_DIPSETTING( 0x20, "2" )
  228.     PORT_DIPSETTING( 0x30, "3" )
  229.     PORT_DIPSETTING( 0x00, "4" )
  230.     PORT_DIPSETTING( 0x10, "5" )
  231.     PORT_DIPNAME(    0x40, 0x40, DEF_STR( Difficulty ) )
  232.     PORT_DIPSETTING( 0x00, "Easy" )
  233.     PORT_DIPSETTING( 0x40, "Medium" )
  234.     PORT_DIPNAME(    0x80, 0x80, "Demo Mode" )
  235.     PORT_DIPSETTING( 0x80, DEF_STR( Off ) )
  236.     PORT_DIPSETTING( 0x00, DEF_STR( On ) )
  237.  
  238.     PORT_START    /* IN4 */
  239.     PORT_ANALOG( 0xff, 0x80, IPT_AD_STICK_Y | IPF_CENTER, 70, 50, 95, 159 )
  240.  
  241.     PORT_START    /* IN5 */
  242.     PORT_ANALOG( 0xff, 0x80, IPT_AD_STICK_X | IPF_REVERSE | IPF_CENTER, 50, 50, 95, 159 )
  243.  
  244. INPUT_PORTS_END
  245.  
  246.  
  247. static struct GfxLayout charlayout =
  248. {
  249.     8,8,    /* 8*8 characters */
  250.     64,    /* 64 characters */
  251.     1,      /* 1 bit per pixel */
  252.     { 0 }, /* the bitplanes are packed in one nibble */
  253.     { 4, 5, 6, 7, 12, 13, 14, 15},
  254.     { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16},
  255.     16*8   /* every char takes 16 consecutive bytes */
  256. };
  257.  
  258. static struct GfxDecodeInfo gfxdecodeinfo[] =
  259. {
  260.     { REGION_GFX1, 0, &charlayout, 64, 16 },
  261.     { -1 }
  262. };
  263.  
  264. static struct POKEYinterface pokey_interface =
  265. {
  266.     4,    /* 4 chips */
  267.     1250000,    /* 1.25 MHz??? */
  268.     { 25, 25, 25, 25 },
  269.     /* The 8 pot handlers */
  270.     { 0, 0, 0, 0 },
  271.     { 0, 0, 0, 0 },
  272.     { 0, 0, 0, 0 },
  273.     { 0, 0, 0, 0 },
  274.     { 0, 0, 0, 0 },
  275.     { 0, 0, 0, 0 },
  276.     { 0, 0, 0, 0 },
  277.     { 0, 0, 0, 0 },
  278.     /* The allpot handler */
  279.     { input_port_4_r, 0, 0, 0 },
  280. };
  281.  
  282.  
  283. static struct MachineDriver machine_driver_irobot =
  284. {
  285.     /* basic machine hardware */
  286.     {
  287.         {
  288.             CPU_M6809,
  289.             1500000,    /* 1.5 Mhz */
  290.             readmem,writemem,0,0,
  291.             ignore_interrupt,0        /* interrupt handled by scanline callbacks */
  292.          },
  293.     },
  294.     60, DEFAULT_REAL_60HZ_VBLANK_DURATION,    /* frames per second, vblank duration */
  295.     1,
  296.     irobot_init_machine,
  297.  
  298.     /* video hardware */
  299.     32*8, 32*8, { 0*8, 32*8-1, 0*8, 29*8-1 },
  300.     gfxdecodeinfo,
  301.     64 + 32,64 + 32, /* 64 for polygons, 32 for text */
  302.     irobot_vh_convert_color_prom,
  303.  
  304.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
  305.     0,
  306.     irobot_vh_start,
  307.     irobot_vh_stop,
  308.     irobot_vh_screenrefresh,
  309.  
  310.     /* sound hardware */
  311.     0,0,0,0,
  312.     {
  313.         {
  314.             SOUND_POKEY,
  315.             &pokey_interface
  316.         }
  317.     },
  318.  
  319.     nvram_handler
  320. };
  321.  
  322.  
  323.  
  324. /***************************************************************************
  325.  
  326.   Game driver(s)
  327.  
  328. ***************************************************************************/
  329.  
  330. ROM_START( irobot )
  331.     ROM_REGION( 0x20000, REGION_CPU1 ) /* 64k for code + 48K Banked ROM*/
  332.     ROM_LOAD( "136029.208",     0x06000, 0x2000, 0xb4d0be59 )
  333.     ROM_LOAD( "136029.209",     0x08000, 0x4000, 0xf6be3cd0 )
  334.     ROM_LOAD( "136029.210",     0x0c000, 0x4000, 0xc0eb2133 )
  335.     ROM_LOAD( "136029.405",     0x10000, 0x4000, 0x9163efe4 )
  336.     ROM_LOAD( "136029.206",     0x14000, 0x4000, 0xe114a526 )
  337.     ROM_LOAD( "136029.207",     0x18000, 0x4000, 0xb4556cb0 )
  338.  
  339.     ROM_REGION( 0x14000, REGION_CPU2 )  /* mathbox region */
  340.     ROM_LOAD_ODD ( "ir103.bin", 0x0000,  0x2000, 0x0c83296d )    /* ROM data from 0000-bfff */
  341.     ROM_LOAD_EVEN( "ir104.bin", 0x0000,  0x2000, 0x0a6cdcca )
  342.     ROM_LOAD_ODD ( "ir101.bin", 0x4000,  0x4000, 0x62a38c08 )
  343.     ROM_LOAD_EVEN( "ir102.bin", 0x4000,  0x4000, 0x9d588f22 )
  344.     ROM_LOAD( "ir111.bin",      0xc000,  0x0400, 0x9fbc9bf3 )    /* program ROMs from c000-f3ff */
  345.     ROM_LOAD( "ir112.bin",      0xc400,  0x0400, 0xb2713214 )
  346.     ROM_LOAD( "ir113.bin",      0xc800,  0x0400, 0x7875930a )
  347.     ROM_LOAD( "ir114.bin",      0xcc00,  0x0400, 0x51d29666 )
  348.     ROM_LOAD( "ir115.bin",      0xd000,  0x0400, 0x00f9b304 )
  349.     ROM_LOAD( "ir116.bin",      0xd400,  0x0400, 0x326aba54 )
  350.     ROM_LOAD( "ir117.bin",      0xd800,  0x0400, 0x98efe8d0 )
  351.     ROM_LOAD( "ir118.bin",      0xdc00,  0x0400, 0x4a6aa7f9 )
  352.     ROM_LOAD( "ir119.bin",      0xe000,  0x0400, 0xa5a13ad8 )
  353.     ROM_LOAD( "ir120.bin",      0xe400,  0x0400, 0x2a083465 )
  354.     ROM_LOAD( "ir121.bin",      0xe800,  0x0400, 0xadebcb99 )
  355.     ROM_LOAD( "ir122.bin",      0xec00,  0x0400, 0xda7b6f79 )
  356.     ROM_LOAD( "ir123.bin",      0xf000,  0x0400, 0x39fff18f )
  357.     /* RAM data from 10000-11fff */
  358.     /* COMRAM from   12000-13fff */
  359.  
  360.     ROM_REGION( 0x800, REGION_GFX1 | REGIONFLAG_DISPOSE)
  361.     ROM_LOAD( "136029.124",     0x0000,  0x0800, 0x848948b6 )
  362.  
  363.     ROM_REGION( 0x0020, REGION_PROMS )
  364.     ROM_LOAD( "ir125.bin",      0x0000,  0x0020, 0x446335ba )
  365. ROM_END
  366.  
  367.     /*  Colorprom from John's driver. ? */
  368.     /*  ROM_LOAD( "136029.125",    0x0000, 0x0020, 0xc05abf82 ) */
  369.  
  370.  
  371.  
  372. GAMEX( 1983, irobot, 0, irobot, irobot, irobot, ROT0, "Atari", "I, Robot", GAME_NO_COCKTAIL )
  373.